package com.snail.snailvr.widget;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by snail on 16/4/26.
 */
public class DownloadView extends ViewGroup {
    ObjectAnimator mObjectAnimator=new ObjectAnimator();

    private View mCloud;
    private View mArrow;
    public DownloadView(Context context) {
        super(context);
    }

    public DownloadView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        mCloud=getChildAt(0);
        measureChildWithMargins(mCloud, widthMeasureSpec, 0, heightMeasureSpec, 0);

        mArrow=getChildAt(1);
        measureChildWithMargins(mArrow, widthMeasureSpec, 0, heightMeasureSpec, 0);

        setMeasuredDimension(mCloud.getMeasuredWidth(), mCloud.getMeasuredHeight());

    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        mCloud = getChildAt(0);
        mCloud.layout(0, 0, mCloud.getMeasuredWidth(), mCloud.getMeasuredHeight());
        //source
        mArrow = getChildAt(1);
        mArrow.layout((mCloud.getMeasuredWidth()-mArrow.getMeasuredWidth())/2, mCloud.getMeasuredHeight()-mArrow.getMeasuredHeight()
                , (mCloud.getMeasuredWidth()+mArrow.getMeasuredWidth())/2, mCloud.getMeasuredHeight());
    }
}
